﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VOL.Entity.DomainModels.Devices.MongoDbModels;

namespace VOL.Core.DbContext
{
    public class MongoDbContext: Microsoft.EntityFrameworkCore.DbContext
    {
        public DbSet<MeasureInfo> MeasureInfo { get; init; }
        public DbSet<CommandLog> CommandLog { get; init; }
        public DbSet<DeviceUpgrade> DeviceUpgrade { get; init; }
        public MongoDbContext(DbContextOptions options)
       : base(options)
        {
        }


        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);


            modelBuilder.Entity<MeasureInfo>()
                .HasIndex(m=>m.uploadTime);//添加索引
            modelBuilder.Entity<CommandLog>()
                .HasIndex(c=>c.createTime);//添加索引
            modelBuilder.Entity<DeviceUpgrade>()
             .HasIndex(c => c.DeviceId);//添加索引
        }
    }
}
